package cn.bobohost.user.web.controller;


import cn.bobohost.user.pojo.ResultDTO;
import cn.bobohost.user.pojo.ResultPageDTO;
import cn.bobohost.user.pojo.User;
import cn.bobohost.user.service.UserService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author bobohost
 * @since 2020-08-15
 */
@RestController
@RequestMapping("//user")
@CrossOrigin
public class UserController {
    //注入service
    @Autowired
    private UserService userService;

    //分页查询
    @PostMapping("/{pageNum}/{pageSize}")
    public ResultDTO listPage(@RequestBody Map<String,Object> paramMap, @PathVariable int pageNum, @PathVariable int pageSize){
        Page<User> pageResponse = userService.findUserListPage(paramMap, pageNum, pageSize);

        return new ResultDTO(true,"查询成功",new ResultPageDTO<>(
                pageResponse.getTotal(),
                pageResponse.getRecords()
        ));
    }
}
